@extends('agent.mainlayout')
@section('title')
    <div class="title"><span>订单管理></span></div>
@endsection

@section('content')
        <!-- start 订单管理-->
    <style type="text/css">
        #sousuo{
            display:inline-block;
            background: #347c1e;
            color:white;
            height:25px;
            margin-left: 40px;
            cursor: pointer;
        }
        #sousuo:hover{
            background-color: #2d94e8;
        }
    </style>
    <div class="list4">
        <div class="header">
            <a href="{{url('center/order?p=0&status=0')}}"><p>待发货</p></a>
            <a href="{{url('center/order?p=2&status=1')}}"><p class="active">已发货</p></a>
        </div>
        <div class="main_top" >
            <form id='search' action="{{url('center/order')}}" method="get">
            <span>选择时间段</span>
            <input type="hidden" name="p" value="2"/>
            <input type="hidden" name="status" value="1"/>
            <input type="text" name="starttime" class="laydate-icon" id="hello2"/><span>到</span>
            <input type="text" name="endtime" class="laydate-icon" id="hello3"/>
            <span id="sousuo" >提交</span>
            </form>
        </div>



        <!--待确认table-->
        <table class="tab_one" id="kuxuan">
            <tr>
                <th>订单号</th>
                <th>商品</th>
                <th>购买人</th>
                <th>数量</th>
                <th>金额</th>
                <th>时间</th>
                <th>操作</th>
            </tr>
            @if(!empty($res['data']))
                @foreach($res['data'] as $v)
            <tr>
                <td>{{$v['order_sn']}}</td>
                <td>{{$v['goods_name']}}</td>
                <td>{{$v['name']}}</td>
                <td>{{$v['goods_num']}}</td>
                <td>{{$v['goods_price']}}</td>
                <td>{{$v['created_at']}}</td>
                <td><a href="{{urlAdmin('Order','getOrderDetail',['id'=>$v['id']])}}"><span style="color:red">查看详情</span></a></td>
            </tr>
                @endforeach
            @else
                <tr>
                    <td colspan="8">暂无数据...</td>
                </tr>
           @endif
        </table>

        <div class="del">
            @if(isset($res['last_page'])&&$res['last_page']>1)
            <div class="bot">
                @if($res['prev_page_url'])
                    <p class="prev"><a href="{{$res['prev_page_url']}}&p=2&status=1">上一页</a></p>
                @endif
                <ul>
                    @foreach($res['pageNoList'] as $v)
                        <li @if($res['current_page'] ==  $v )class="active_list" @endif ><a href="/center/order?p=2&status=1&page={{$v}}">{{$v}}</a></li>
                    @endforeach
                </ul>
                @if($res['next_page_url'])
                    <p class="next"><a href="{{$res['next_page_url']}}&p=2&status=1">下一页</a></p>
                @endif
            </div>
            @endif
        </div>
    </div>

@endsection
<script>


    function Confirm(id){

        layer.confirm('确认收款?',{btn: ['确定','取消']},function(){
            layer.closeAll();
            //加载效果
            layer.load(2, {shade: false});

            $url = "{{url('center/order/change')}}?id="+id;

            $.ajax({
                type:"GET",
                url:$url,
                dataType:"json",
                success:function(res){

                    //关闭加载效果
                    layer.closeAll("loading");

                    if (res['status']==1){
                        layer.msg('操作成功', {icon: 6});
                        setTimeout("location.reload()",1500);
                    }else{
                        layer.msg('操作失败', {icon: 5});
                    }

                }
            })

        },function(){

        });
    }
    window.onload = function () {
        /****酷炫效果*****/
        var oTable = document.getElementById('kuxuan');
        var aLi = oTable.getElementsByTagName('tr');
        //var arr = ['red','blue','grey'];
        var str = '';
        for(var i=1;i<aLi.length;i++){

            //aLi[i].style.background = arr[i%3];

            aLi[i].onmouseover = function(){
                str = this.style.background;      //将原来的颜色保存起来
                this.style.background = '#2bdacf';
            }

            aLi[i].onmouseout = function(){
                this.style.background = str;
            }

        }
        /****酷炫效果******/



        //时间搜索
        var oSousuo = document.getElementById('sousuo');
        var oSearch = document.getElementById('search');

        oSousuo.onclick = function(){
            //加载效果
            layer.load(2, {shade: false});
            oSearch.submit();

        }

        laydate({
            elem: '#hello2'
        });
        laydate({
            elem: '#hello3'
        });


        // 显示编辑 并发送ajax 获取数据





    }


</script>